define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'shop.goods/index',
        add_url: 'shop.goods/add',
        edit_url: 'shop.goods/edit',
        delete_url: 'shop.goods/delete',
        export_url: 'shop.goods/jsExport',
        modify_url: 'shop.goods/modify',
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                cols: [[
                    {type: 'checkbox'},
                    {field: 'id', title: 'ID', width: 80},
                    {field: 'goods_name', title: '商品名称', edit:'text', width: 120},
                    {field: 'cate.title', title: '分类', width: 80},
                    {field: 'store.title', title: '店铺',width: 120},
                    {field: 'brief', title: '商品简介', edit:'text', search: false},
                    {field: 'goods_cover', title: '商品封面', templet: ea.table.image, width: 100, search: false},
                    {field: 'price', title: '参考价格', edit:'text', width: 100},
                    {field: 'status', title: '产品状态', width:90, selectList: {1: '上架', 0: '下架'}, templet: ea.table.switch, tips: '上架|下架'},
                    {field: 'sort', title: '权重', edit:'text', width: 80, search: false},
                    {field: 'create_time', title: '创建时间', search: 'range'},
                    {width: 250, title: '操作', templet: ea.table.tool},
                ]],
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
    };
    return Controller;
});